package com.codoon.unova.util;

import java.io.IOException;
import java.util.Properties;

/**
 * 工厂类
 * 
 * @author yuanjian
 * 
 */
public class BeanFactory {
	private static Properties properties;
	static {
		properties = new Properties();
		try {
			properties.load(BeanFactory.class.getClassLoader().getResourceAsStream("config.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static <T> T getImpl(Class<T> clazz) {
		String simpleName = clazz.getSimpleName();
		String property = properties.getProperty(simpleName);
		try {
			return (T) Class.forName(property).newInstance();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
